package com.cdh.oa.util;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ResponseData {
    private Integer code; //标识 0成功  1失败
    private String msg;   //提示信息
    private Long count;   //分页总条数
    private Object data;  //携带的数据

    /**
     * 分页返回
     * @param count  分页前端所需总条数
     * @param data   显示的分页数据
     * @return
     */
    public static ResponseData okPage(long count,Object data){
        return new ResponseData(0,null,count,data);
    }

    /**
     * 操作成功，返回提示信息
     * @param msg
     * @return
     */
    public static ResponseData okMsg(String msg){
        return new ResponseData(0,msg,null,null);
    }

    /**
     * 操作成功，返回大量数据
     * @param data
     * @return
     */
    public static ResponseData okData(Object data){
        return new ResponseData(0,null,null,data);
    }

    /**
     * 操作失败，返回提示信息
     * @param msg
     * @return
     */
    public static ResponseData fail(String msg){
        return new ResponseData(1,msg,null,null);
    }

}
